<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
</html>
<script>
    function throttle(fn, threshold) {
        let last;
        let timer;
        threshold || (threshold = 250);

        return function () {
            let context = this, args = arguments;
            let now = new Date();

            if (last && now - last < threshold) {
                // 如果在指定的时间内，则重置定时器
                clearTimeout(timer);
                timer = setTimeout(function () {
                    last = now;
                    fn.apply(context, args);
                }, threshold);
            } else {
                // 如果超过了指定的时间，则直接执行函数
                last = now;
                fn.apply(context, args);
            }
        };
    }

    const doRequest = throttle(uniRequest, 5000)

    function uniRequest(channel_name, push) {
        console.log(222222222222)
    }

    setInterval(()=> {
        doRequest('name', 'push')
        console.log('go')
    }, 1000)

</script>
